package com.eastfair.gateway.config;


import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import com.eastfair.database.datasource.BaseMybatisConfiguration;
import com.eastfair.database.datasource.LampMetaObjectHandler;
import com.eastfair.database.properties.DatabaseProperties;
import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Repository;

import static com.eastfair.constant.BizConstant.UTIL_PACKAGE;


/**
 * 配置一些 Mybatis 常用重用拦截器
 *
 * @author ligang
 * @date 2017-11-18 0:34
 */
@Configuration
@Slf4j
@EnableConfigurationProperties({DatabaseProperties.class})



//@EnableConfigurationProperties(DataSourceProperties.class)
//@AutoConfigureBefore(DataSourceAutoConfiguration.class)
//@Import(value = {DruidDynamicDataSourceConfiguration.class, DynamicDataSourceCreatorAutoConfiguration.class})
//@EnableAutoConfiguration(exclude = {DruidDataSourceAutoConfigure.class})
//@MapperScan(basePackages = {UTIL_PACKAGE,}, annotationClass = Repository.class)

//引入sharding
//@AutoConfigureBefore({SpringBootConfiguration.class})

public class ActivitiMybatisAutoConfiguration extends BaseMybatisConfiguration {
    public ActivitiMybatisAutoConfiguration(DatabaseProperties databaseProperties) {
        super(databaseProperties);
    }

    /**
     * Mybatis Plus 注入器
     *
     * @return 注入器
     */
    @Bean("myMetaObjectHandler")
    @ConditionalOnMissingBean
    public MetaObjectHandler getMyMetaObjectHandler() {
        return new LampMetaObjectHandler();
    }

}
